<template>
  <!-- 对话框 添加角色 ==修改角色都是用同一个对话框 -->
  <el-dialog :title="diaBox=='edit'?'编辑角色':'添加角色'" :visible="dialogFormVisible" @close="close">
    <el-form :model="formAdd">
      <el-form-item label="角色名称" :label-width="formLabelWidth">
        <el-input v-model="formAdd.name" autocomplete="off" />
      </el-form-item>
      <el-form-item label="角色名称" :label-width="formLabelWidth">
        <el-input v-model="formAdd.description" autocomplete="off" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="close">取 消</el-button>
      <el-button type="primary" @click="roleHandle">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: '',
  props: {
    dialogFormVisible: {
      type: Boolean,
      default: false
    },
    diaBox: {
      type: String,
      default: ''
    },
    formAdd: {
      type: Object,
      default: () => {
        return {
          name: '',
          description: ''
        }
      }
    }
  },
  data() {
    return {
      // formAdd: {
      //   name: '',
      //   description: ''
      // },
      formLabelWidth: '120px'
    }
  },
  methods: {
    close() {
      this.$emit('update:dialogFormVisible', false)
      this.$emit('update:formAdd', {
        name: '',
        description: ''
      })
    },
    //  点击确认按钮
    roleHandle(params) {
      this.$emit('roleHandle', params)
    }
  }
}

</script>
<style lang='less' scoped>

</style>
